package com.rede.didiok.user.web;

import java.util.List;

import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import com.rede.didiok.common.dto.ReportOption;
import com.rede.didiok.common.dto.user.ReportDto;
import com.rede.didiok.common.exception.ThrowableUtils;
import com.rede.didiok.common.utils.ResultUtil;
import com.rede.didiok.common.validator.group.GetList;
import com.rede.didiok.user.service.ReportService;



/**
 * 内容举报信息
 *
 * @author Rede
 * @email didiok@foxmail.com
 * @date 2023-08-07 18:21:17
 */
@RestController
@RequestMapping("user/feign/report")
public class ReportController {
    @Autowired
    private ReportService reportService;

    @ApiOperation(value = "获取举报列表", notes = "获取举报列表", response = String.class)
    @PostMapping("/getList")
    public String getList(@Validated({GetList.class}) @RequestBody ReportDto reportDto, BindingResult result) {

        ThrowableUtils.checkParamArgument(result);
        return ResultUtil.successWithData(reportService.getPageList(reportDto));
    }

    @ApiOperation(value = "批量删除举报列表", notes = "批量删除举报列表", response = String.class)
    @PostMapping("/deleteBatch")
    public String deleteBatch(@RequestBody List<String> reportUidList) {
        return reportService.batchDeleteReport(reportUidList);
    }

    /**
     * 获取举报信息
     *
     * @param reportOption
     * @return
     */
    @ApiOperation(value = "获取举报信息", notes = "获取举报信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "keyword", value = "关键词", required = false),
            @ApiImplicitParam(name = "currentPage", value = "当前页数", required = true),
            @ApiImplicitParam(name = "pageSize", value = "每页显示数目", required = true)
    })
    @PostMapping("/list")
    public String list(@RequestBody ReportOption reportOption) {
        return ResultUtil.successWithData(reportService.queryListByContent(reportOption));
    }

    /**
     * 处理举报信息
     * @param reportContentUid
     * @param reportType
     * @param reportUid
     * @param progress
     * @return
     */
    @ApiOperation(value = "处理举报信息", notes = "处理举报信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "reportContentUid", value = "被举报稿件Uid", required = true),
            @ApiImplicitParam(name = "reportType", value = "举报的稿件类型", required = true),
            @ApiImplicitParam(name = "progress", value = "处理状态", required = true),
            @ApiImplicitParam(name = "reportUid", value = "举报记录的Uid", required = false)
    })
    @PostMapping("/handle")
    String handleReport(@RequestParam("reportContentUid") String reportContentUid,
                        @RequestParam("reportType") String reportType,
                        @RequestParam("reportUid") String reportUid,
                        @RequestParam("progress") Integer progress){
        return reportService.handleReport(reportContentUid,reportType,reportUid,progress);

    }

}

